layui.use(['upload','layer','commons','form'],function() {
    var $ = layui.jquery,
        layer = layui.layer,
        common = layui.commons,

        form = layui.form;

    var user = getUser();
    try{
        var userName = user.name;
        $("#user-name").text(userName);
    }catch(error){
        console.log(error);
    }

    /**登出*/
    $("#logout").click(function(){
        //获取当前用户
        var user = getUser();
        //格式化数据
        var fmtd = formatData(user);
        /**退出登录*/
        common.ajax('/service-authorization/user/logout',JSON.stringify(fmtd),function(data){

            if(data.data == null || data.data == ''){
                layer.msg(data.msg);
            }else {
                layer.msg('登出成功',{icon: 6, time: 500}, function () {
                    window.sessionStorage.removeItem('user');
                    layer.closeAll();
                    location.href = './login.html';
                });
            }

        },'post',true,function(error){
            console.log(error);
            layer.closeAll();
        });
    });




})
